#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main()
{
  //int fd = open("log.txt",O_WRONLY|O_CREAT|O_TRUNC,0666);
  int fd = open("log.txt",O_RDONLY);
  dup2(fd,0);
  char buffer[1024];
  while(1)
  {
    //默认情况，stdin从键盘中取到，默认是要阻塞的
    char* s = fgets(buffer,sizeof(buffer),stdin);//stdin -> FILE* -> _fileno
    if(!s) break;
    printf("file contest:%s",buffer);
  }
  return 0;
}
